import AgentService from '../../public/widget';
import axios from './axios';
import { cleanParams } from '@/utils';

export const login = () => {
	return axios({
		url: AgentService.Agent.configure.serviceUrl + `/ivcs/mindary/sso`,
		method: 'get',
		headers: {
			'Content-Type': 'application/json'
		}
	});
};

export const osslogin = (data: { code: string }) => {
	return axios({
		url: AgentService.Agent.configure.serviceUrl + `/ivcs/mindary/sso/login`,
		method: 'post',
		data,
		headers: {
			'Content-Type': 'application/json'
		}
	});
};

export const getRecordList = (params: {
	sn?: string;
	orderId?: string;
	phone?: string;
	sessionStartAt?: any;
	sessionEndAt?: any;
	agentName?: string;
	isAccepted?: boolean;
	score?: string;
	page: number;
	pageSize: number;
}) => {
	return axios({
		url: AgentService.Agent.configure.serviceUrl + `/ivcs/mindary/workOrder/own`,
		method: 'get',
		params: cleanParams(params),
		headers: {
			'Content-Type': 'application/json',
			'x-access-token': AgentService.Agent.token
		}
	});
};

export const sendMoblieMessage = (data: { phone: string; content: string }) => {
	return axios({
		url: AgentService.Agent.configure.serviceUrl + `/ivcs/mindary/sendMsg`,
		method: 'post',
		data,
		headers: {
			'Content-Type': 'application/json',
			'x-access-token': AgentService.Agent.token
		}
	});
};

// export const getUserCallInfo = (sessionID: string) => {
// 	return axios({
// 		url: AgentService.Agent.configure.serviceUrl + `/ivcs/mindary/session/${sessionID}/customer`,
// 		method: 'get',
// 		headers: {
// 			'Content-Type': 'application/json',
// 			'x-access-token': AgentService.Agent.token
// 		}
// 	});
// };

// export const getUserDevices = (sessionID: string) => {
// 	return axios({
// 		url: AgentService.Agent.configure.serviceUrl + `/ivcs/mindary/session/${sessionID}/device`,
// 		method: 'get',
// 		headers: {
// 			'Content-Type': 'application/json',
// 			'x-access-token': AgentService.Agent.token
// 		}
// 	});
// };

export const getUserDevices = (sessionID: string) => {
	return axios({
		url: AgentService.Agent.configure.serviceUrl + `/ivcs/mindary/session/${sessionID}/orderInfo`,
		method: 'get',
		headers: {
			'Content-Type': 'application/json',
			'x-access-token': AgentService.Agent.token
		}
	});
};

export const modifyWorkOrder = (
	data: {
		ZSLD_CODE?: string; // 工单状态
		ZZCFS_CODE?: string; // 支持方式
		ZWXZC_CODE?: string; // 无需技术支持原因
		ZQTYY?: string; // 其他原因
		ZPGYY_CODE?: string; // 派工原因
		ZTS_CODE: string; // 工号
		ZCLXX_TEXT?: string; // 处理信息
		ZLXR_NAME?: string; // 联系人姓名
		ZLXR_TEL?: string; // 联系人电话
		ZLCPXLB_TEXT?: string; // 临床服务类别
	},
	sessionID: string
) => {
	return axios({
		url: AgentService.Agent.configure.serviceUrl + `/ivcs/mindary/workOrder/detail/${sessionID}`,
		method: 'post',
		data,
		headers: {
			'Content-Type': 'application/json',
			'x-access-token': AgentService.Agent.token
		}
	});
};

export const exportRecordList = () => {
	return axios({
		url: AgentService.Agent.configure.serviceUrl + `/ivcs/mindary/workOrder/export`,
		method: 'get',
		headers: {
			'Content-Type': 'application/json',
			'x-access-token': AgentService.Agent.token
		},
		responseType: 'arraybuffer'
	});
};
